package com.example.finalassignment.exception;


import com.example.finalassignment.pojo.response.ResultResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 全局异常处理
 */

@ControllerAdvice
public class MyExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public ResultResponse resultResponse(ServiceException serviceException){
        return ResultResponse.fail(serviceException.getCode(),serviceException.getMessage());
    }
}
